package ch.sv7.tool.dbmanager.db.difference;

import ch.sv7.tool.dbmanager.db.IndexSchema;
import ch.sv7.tool.dbmanager.db.TableSchema;

public class MissingIndexDifference extends AbstractTableDifference {

	private IndexSchema index;

	public MissingIndexDifference(TableSchema expectedTableSchema, TableSchema actualTableSchema, IndexSchema index) {
		super(expectedTableSchema, actualTableSchema);
		this.index = index;
	}

	/**
	 * @return the index
	 */
	public IndexSchema getIndex() {
		return index;
	}

	public String getMessage() {
		return super.getMessage() 
			+ " index " 
			+ (getIndex().isUnique() ? "[unique]" : "[non-unique]") 
				+ " on column(s): " + getIndex().getColumns()+ " - is missing";
	}

	public boolean isBlocker() {
		return index.isUnique();
	}
	
}
